﻿using System;
using System.Collections.Generic;
using System.Text;

namespace HAVNet.Intros.AST
{
    public class ASTMemberDeclField : ASTMemberDeclStruct
    {
        ASTVariableDeclarators _variableDeclarators = null;

        public bool     isPartial   { get; set; }
        public ASTType  type        { get; set; }
        public ASTVariableDeclarators variableDeclarators { get { if (null == _variableDeclarators) _variableDeclarators = new ASTVariableDeclarators(); return _variableDeclarators; } }

        public override string ToString ()
        {
            //  fieldsMod =
            //      newMod      |
            //      publicMod   |
            //      protectedMod|
            //      internalMod |
            //      privateMod  |
            //      unsafeMod   |
            //      staticMod   |
            //      readonlyMod |
            //      volatileMod

            string mods = "";

            if (Mods.has(modifiers, Mods.newMod         )) mods += "new ";
            
            if (Mods.has(modifiers, Mods.publicMod      )) mods += "public ";
            if (Mods.has(modifiers, Mods.protectedMod   )) mods += "protected ";
            if (Mods.has(modifiers, Mods.internalMod    )) mods += "internal ";
            if (Mods.has(modifiers, Mods.privateMod     )) mods += "private ";

            if (Mods.has(modifiers, Mods.unsafeMod      )) mods += "unsafe ";
            if (Mods.has(modifiers, Mods.staticMod      )) mods += "static ";
            if (Mods.has(modifiers, Mods.readonlyMod    )) mods += "readonly ";
            if (Mods.has(modifiers, Mods.volatileMod    )) mods += "volatile ";

            return
                mods +
                (isPartial ? " partial " : "") +
                type.ToString() + " " +
                variableDeclarators.ToString() + ";" + Environment.NewLine;
        }
    }
}
